<include file="Public/header" />
<title>添加订单</title>
</head>
<body>
<div class="pd-20">
<form name="form" id="form" method="post">
	<table class="table table-border table-bordered table-bg">

		<tbody>
			<tr class="text-c">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">订单编号：</td>
					<td class="text-l">
						<input type="hidden" class="input-text" value="OD<{:date('ymd',time())}><{$serial_number}>" placeholder="订单编号" id="order_no" name="order_no">
						<input type="text" class="input-text" value="OD<{:date('ymd',time())}><{$serial_number}>" placeholder="订单编号"  disabled="disabled">
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">申请部门：</td>
					<td class="text-l" style="width:35%;">
						<select  class="input-text" id="section_no" name="section_no">
							<option value="0">请选择</option>
							<volist name="section_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['section_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
					</td>						
			</tr>
			<tr class="text-c">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">制单人：</td>
					<td class="text-l">
						<select  class="input-text people_make_no" id="people_make_no" name="people_make_no">
							<option value="0">请选择</option>
							<volist name="personnel_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['people_make_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
						
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">业务员：</td>
					<td class="text-l">
						<select  class="input-text people_purchasing_no" id="people_purchasing_no" name="people_purchasing_no">
							<option value="0">请选择</option>
							<volist name="personnel_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['people_purchasing_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
					</td>						
			</tr>
			<tr class="text-c">
					<td width="15%" class="text-r" style="background-color:#f5f5f5">往来单位：</td>
					<td class="text-l">
						<select  class="input-text contacts_company_no" id="contacts_company_no" name="contacts_company_no">
							<option value="0">请选择</option>
							<volist name="company_list" id="vo">
								<option value="<{$vo.no}>" <if condition="$vo['no'] eq $detail['contacts_company_no']">selected</if>><{$vo.name}></option>
							</volist>
						</select>
						
					</td>
					<td width="15%" class="text-r" style="background-color:#f5f5f5">运输方式：</td>
					<td class="text-l">
						<select  class="input-text transport_cate" id="transport_cate" name="transport_cate">
							<option value="0">请选择</option>
							<option value="1">自提</option>
							<option value="2">第三方物流</option>
							<option value="3">送货</option>
						</select>
						<input type="text" name="logistics_no" style="display:none" class="input-text" value="" placeholder="运单号">
					</td>						
			</tr>
			
		</tbody>
	</table>
</form>
		<div class="row cl">
			<div class="col-9 col-offset-3">
				<input class="btn btn-primary radius" type="submit" id="add" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>

</div>
<script type="text/javascript">
    $(function(){
		$(".transport_cate").change(function(){
			if($(this).val()==2){
				$('input[name=logistics_no]').show();
			}else{
				$('input[name=logistics_no]').hide();
			}
		});
		/*删除*/
        $("#add").click(function(){
			var section_no=$('#section_no').val();
			var order_no=$('#order_no').val();
			var people_make_no=$('.people_make_no').val();
			var people_purchasing_no=$('.people_purchasing_no').val();
			var user_name=$('.user_name').val();
			
            //询问
			if(order_no==""){
				layer.alert("订单编号不能为空");
				return false;
			}
			if(section_no=="0"){
				layer.alert("申请部门不能为空");
				return false;
			}
			if(people_make_no=="0"){
				layer.alert("请选择制单人");
				return false;
			}
			if(people_purchasing_no=="0"){
				layer.alert("请选择采购申请人");
				return false;
			}
			if(user_name==""){
				layer.alert("客户姓名不能为空");
				return false;
			}
			layer.confirm('是否确定添加此信息', {
			  btn: ['是','否'] 
			}, function(){
				$.ajax({
					type: 'POST',
					data: $("#form").serialize(),
					url: "<{:U('add')}>",
					success:function(data){
						layer.alert(data.info,function(){
							parent.window.location.href =parent.window.location.href;
						});
					}
				})
			});
        });

    })
</script>

</body>
</html>